package com.aiseed.controller;

import com.aiseed.entity.User;
import com.aiseed.mapper.UserMapper;
import com.aiseed.service.IUserService;
import com.aiseed.utils.Result;
import com.aiseed.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {
    @Autowired
    UserMapper userMapper;
    @Autowired
    IUserService userService;
    @RequestMapping("/get")
    public User getUser(){
        User user=new User("1001","testman","12345");
        return user;
    }
    @RequestMapping("/list")
    public List<User> getUsers(){
        List<User> list=userMapper.selectList(null);
        return list;
    }
    @RequestMapping("/login")
    public Result login(User user){
        boolean isLogin=userService.login(user.getUsername(),user.getPassword());
        Result result=ResultUtils.success(isLogin);
        return result;
    }
}
